package app

import (
	"fmt"

	"github.com/garyburd/redigo/redis"
)

func init() {
	var redisCreator RedisCreator
	redisCreator.redis_host = "127.0.0.1"
	redisCreator.redis_port = 6379
	redisCreator.pool_size = 20
}

type RedisCreator struct {
	redis_host string
	redis_port int32
	pool_size  int
}

var redisCreator RedisCreatorInterface = RedisCreator{}

func (this RedisCreator) make() *redis.Pool {
	fmt.Println("init redis")
	return redis.NewPool(func() (redis.Conn, error) {
		c, err := redis.Dial("tcp", fmt.Sprintf("%s:%d", this.redis_host, this.redis_port))
		if err != nil {
			return nil, err
		}
		return c, nil
	}, this.pool_size)

}
